<?php // Product Categories ?>
<div>
	<h2>Product Categories</h2>
</div>
<div style="width:100%; margin:0 auto; text-align:left; vertical-align:middle; border-bottom:dashed 1px gray;">
<?php
	$uri = $_SERVER['REQUEST_URI'];
	$uri_var = explode('/', $uri);
	
	$count = count($uri_var);
	if(substr($uri,-1,1) == "/")
	{
		$count = $count-2;
	}
	else
	{
		$count = $count-1;
	}
	
	for( $i = 0; $i <= $count; $i++ )
	{
		$var_name[] = "uri_" . $i;
	}
	
	for( $i = 0; $i < $count+1; $i++ )
	{
		${$var_name[$i]}  = $uri_var[$i];
	}

	$sql = "select a.* 
			from tbl_product_category a 
			where 	a.stsrc = 'A' 
				and a.productcategorystatus = 1 
			order by a.productcategoryposition asc
			";
	$exe = mysql_query($sql) or die(mysql_error());
	$num = mysql_num_rows($exe);
	
	if($num > 0)
	{
		$x1 = 1;	// get first row for style border top
		while($row = mysql_fetch_array($exe))
		{
?>
		<?php
			$sql2 = "select a.* 
					from tbl_product_brand a 
					where 	a.stsrc = 'A' 
						and a.productbrandstatus = 1 
						and a.productcategoryid = ".$row['productcategoryid']."
					order by a.productbrandposition asc
					";
			$exe2 = mysql_query($sql2) or die(mysql_error());
			$num2 = mysql_num_rows($exe2);
		?>
		<div style="width:100%;">
		<div class="left_div_href_1">
		<a <?php if(isset($uri_2)){if($uri_2==$row['productcategoryname']){ ?>style="color:#d1a267; font-weight:bold;"<?php }} ?> <?php if($x1 == 1){echo 'class="left_menu_href_first"';}else{echo 'class="left_menu_href"';} ?> href="<?php echo getURLdomain(); ?>/product/<?php echo stripslashes(html_entity_decode($row['productcategoryname'])); ?>" >
			<span><?php echo stripslashes(html_entity_decode($row['productcategorylabel'])); ?><span>
		</a>
		</div>
		<div class="clear"></div>
		</div>
		<?php
			if(isset($uri_var[2]) && $num2 > 0 && $uri_var[2] == $row['productcategoryname'])
			{
				while($row2 = mysql_fetch_array($exe2))
				{
		?>
			<?php
				$sql3 = "select a.* 
						from tbl_product_class a 
						where 	a.stsrc = 'A' 
							and a.productclassstatus = 1 
							and a.productbrandid = ".$row2['productbrandid']."
						order by a.productclassposition asc
						";
				$exe3 = mysql_query($sql3) or die(mysql_error());
				$num3 = mysql_num_rows($exe3);
			?>
			<div style="width:100%;">
			<div class="left_div_href_2">
				<a <?php if(isset($uri_3)){if($uri_3==$row2['productbrandname']){ ?>style="color:#d1a267; font-weight:bold;"<?php }} ?> class="left_menu_href_2" href="<?php echo getURLdomain(); ?>/product/<?php echo stripslashes(html_entity_decode($row['productcategoryname'])); ?>/<?php echo stripslashes(html_entity_decode($row2['productbrandname'])); ?>" >
					<span><?php echo stripslashes(html_entity_decode($row2['productbrandlabel'])); ?></span>
				</a>
			</div>
			<div class="clear"></div>
			</div>
			<?php
					if(isset($uri_var[3]) && $num3 > 0 && $uri_var[3] == $row2['productbrandname'])
					{
						while($row3 = mysql_fetch_array($exe3))
						{
			?>
					<?php
						$sql4 = "select a.* 
								from tbl_product_detail a 
								where 	a.stsrc = 'A' 
									and a.productdetailstatus = 1 
									and a.productclassid = ".$row3['productclassid']."
								order by a.productdetailposition asc
								";
						$exe4 = mysql_query($sql4) or die(mysql_error());
						$num4 = mysql_num_rows($exe4);
					?>
					<div style="width:100%;">
					<div class="left_div_href_3">
						<a <?php if(isset($uri_4)){if($uri_4==$row3['productclassname']){ ?>style="color:#d1a267; font-weight:bold;"<?php }} ?> class="left_menu_href_2" href="<?php echo getURLdomain(); ?>/product/<?php echo stripslashes(html_entity_decode($row['productcategoryname'])); ?>/<?php echo stripslashes(html_entity_decode($row2['productbrandname'])); ?>/<?php echo stripslashes(html_entity_decode($row3['productclassname'])); ?>" >
							<span><?php echo stripslashes(html_entity_decode($row3['productclasslabel'])); ?></span>
						</a>
					</div>
					<div class="clear"></div>
					</div>
					<?php
							if(isset($uri_var[4]) && $num4 > 0 && $uri_var[4] == $row3['productclassname'])
							{
								while($row4 = mysql_fetch_array($exe4))
								{
					?>
							<div style="width:100%;">
							<div class="left_div_href_4">
								<a <?php if(isset($uri_5)){if($uri_5==$row4['productdetailname']){ ?>style="color:#d1a267; font-weight:bold;"<?php }} ?> class="left_menu_href_2" href="<?php echo getURLdomain(); ?>/product/<?php echo stripslashes(html_entity_decode($row['productcategoryname'])); ?>/<?php echo stripslashes(html_entity_decode($row2['productbrandname'])); ?>/<?php echo stripslashes(html_entity_decode($row3['productclassname'])); ?>/<?php echo stripslashes(html_entity_decode($row4['productdetailname'])); ?>" >
									<span><?php echo stripslashes(html_entity_decode($row4['productdetaillabel'])); ?></span>
								</a>
							</div>
							<div class="clear"></div>
							</div>
					<?php
								}
							}
					?>
					<?php
						}
					}
					?>
		<?php
				}
			}
		?>
<?php
		$x1++;
		}
	}
?>
</div>
<div style="padding-bottom:20px;">
&nbsp;
</div>